﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Servicios.Data.DataBases.Biblioteca
{
    public partial class MaterialBibliograficoDTO
    {
        public MaterialBibliograficoDTO()
        { }

        #region IDataTransferObject<MaterialBibliograficoDTO> Members

        public List<MaterialBibliograficoDTO> GetAll()
        {
            using (BibliotecaContext bc = new BibliotecaContext())
            {
                return (from idioma in bc.MaterialBibliograficoSet
                        select idioma).ToList<MaterialBibliograficoDTO>();
            }
        }

        public MaterialBibliograficoDTO GetByID(int id)
        {
            using(BibliotecaContext bib = new BibliotecaContext())
            {
                var q = from mb in bib.MaterialBibliograficoSet where mb.ID == id select mb;
                return q.FirstOrDefault();
            }
        }

        public void Save()
        {
            using (BibliotecaContext bib = new BibliotecaContext())
            {
                bib.AddToMaterialBibliograficoSet(this);
                bib.SaveChanges();
            }
        }

        public void Update()
        {
            throw new NotImplementedException();
        }

        public void Delete()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
